package csdnpractice;

import java.util.Random;
import java.util.Scanner;

public class Practice02 {
    //给定一个长度,随机产生一个该长度的字符串,由大写,小写字母以及数字组成
    //Java中随机数的生成:
    //java.util.Random r = new java.util.Random();
    //int a = r.nextInt(100): a 0-99的随机数
    public static void main(String[] args) {
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        String name = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
        System.out.println("请输入长度:");
        int leg = scanner.nextInt();
        char[] ch = new char[leg];
        int num;
        for (int i=0;i<ch.length;i++){
            num = random.nextInt(name.length());
            ch[i] = name.charAt(num);
        }
        String na1 = String.valueOf(ch);
        System.out.println(na1);
    }
}
